home *** CD-ROM | disk | FTP | other *** search
/ Champak 74 / Volume 74 My Disc - Damaged.iso / Games / TrendyCouple.swf / scripts / __Packages / mochi / MochiScores.as next >
Text File  |  2008-08-11  |  4KB  |  155 lines

  1. class mochi.MochiScores
  2. {
  3.    function MochiScores()
  4.    {
  5.    }
  6.    static function setBoardID(boardID)
  7.    {
  8.       mochi.MochiScores.boardID = boardID;
  9.       mochi.MochiServices.send("scores_setBoardID",{boardID:boardID});
  10.    }
  11.    static function showLeaderboard(options)
  12.    {
  13.       if(options.clip != null)
  14.       {
  15.          if(options.clip != mochi.MochiServices.__get__clip() || mochi.MochiServices.__get__childClip()._target == undefined)
  16.          {
  17.             mochi.MochiServices.disconnect();
  18.             mochi.MochiServices.connect(mochi.MochiServices.__get__id(),options.clip);
  19.          }
  20.          delete options.clip;
  21.       }
  22.       if(options.name != null)
  23.       {
  24.          if(typeof options.name == "object")
  25.          {
  26.             if(options.name.text != undefined)
  27.             {
  28.                options.name = options.name.text;
  29.             }
  30.          }
  31.       }
  32.       if(options.score != null)
  33.       {
  34.          if(typeof options.score == "object")
  35.          {
  36.             if(options.score.text != undefined)
  37.             {
  38.                options.score = options.score.text;
  39.             }
  40.          }
  41.       }
  42.       if(options.onDisplay != null)
  43.       {
  44.          options.onDisplay();
  45.       }
  46.       else
  47.       {
  48.          mochi.MochiServices.__get__clip().stop();
  49.       }
  50.       if(options.onClose != null)
  51.       {
  52.          mochi.MochiScores.onClose = options.onClose;
  53.       }
  54.       else
  55.       {
  56.          mochi.MochiScores.onClose = function()
  57.          {
  58.             mochi.MochiServices.__get__clip().play();
  59.          };
  60.       }
  61.       if(options.onError != null)
  62.       {
  63.          mochi.MochiScores.onError = options.onError;
  64.       }
  65.       else
  66.       {
  67.          mochi.MochiScores.onError = mochi.MochiScores.onClose;
  68.       }
  69.       if(options.boardID == null)
  70.       {
  71.          if(mochi.MochiScores.boardID != null)
  72.          {
  73.             options.boardID = mochi.MochiScores.boardID;
  74.          }
  75.       }
  76.       mochi.MochiServices.send("scores_showLeaderboard",{options:options},null,mochi.MochiScores.doClose);
  77.    }
  78.    static function closeLeaderboard()
  79.    {
  80.       mochi.MochiServices.send("scores_closeLeaderboard");
  81.    }
  82.    static function getPlayerInfo(callbackObj, callbackMethod)
  83.    {
  84.       mochi.MochiServices.send("scores_getPlayerInfo",null,callbackObj,callbackMethod);
  85.    }
  86.    static function submit(score, name, callbackObj, callbackMethod)
  87.    {
  88.       mochi.MochiServices.send("scores_submit",{score:score,name:name},callbackObj,callbackMethod);
  89.    }
  90.    static function requestList(callbackObj, callbackMethod)
  91.    {
  92.       mochi.MochiServices.send("scores_requestList",null,callbackObj,callbackMethod);
  93.    }
  94.    static function scoresArrayToObjects(scores)
  95.    {
  96.       var _loc5_ = {};
  97.       var _loc1_ = undefined;
  98.       var _loc4_ = undefined;
  99.       var _loc2_ = undefined;
  100.       var _loc6_ = undefined;
  101.       for(var _loc8_ in scores)
  102.       {
  103.          if(typeof scores[_loc8_] == "object")
  104.          {
  105.             if(scores[_loc8_].cols != null && scores[_loc8_].rows != null)
  106.             {
  107.                _loc5_[_loc8_] = [];
  108.                _loc2_ = scores[_loc8_];
  109.                _loc4_ = 0;
  110.                while(_loc4_ < _loc2_.rows.length)
  111.                {
  112.                   _loc6_ = {};
  113.                   _loc1_ = 0;
  114.                   while(_loc1_ < _loc2_.cols.length)
  115.                   {
  116.                      _loc6_[_loc2_.cols[_loc1_]] = _loc2_.rows[_loc4_][_loc1_];
  117.                      _loc1_ = _loc1_ + 1;
  118.                   }
  119.                   _loc5_[_loc8_].push(_loc6_);
  120.                   _loc4_ = _loc4_ + 1;
  121.                }
  122.             }
  123.             else
  124.             {
  125.                _loc5_[_loc8_] = {};
  126.                for(var _loc7_ in scores[_loc8_])
  127.                {
  128.                   _loc5_[_loc8_][_loc7_] = scores[_loc8_][_loc7_];
  129.                }
  130.             }
  131.          }
  132.          else
  133.          {
  134.             _loc5_[_loc8_] = scores[_loc8_];
  135.          }
  136.       }
  137.       return _loc5_;
  138.    }
  139.    static function doClose(args)
  140.    {
  141.       if(args.error == true)
  142.       {
  143.          if(args.errorCode == undefined)
  144.          {
  145.             args.errorCode = "IOError";
  146.          }
  147.          mochi.MochiScores.onError.apply(null,[args.errorCode]);
  148.       }
  149.       else
  150.       {
  151.          mochi.MochiScores.onClose.apply();
  152.       }
  153.    }
  154. }
  155.